//
//  EmotionAttachment.swift
//  表情键盘
//
//  Created by mac on 15/5/24.
//  Copyright (c) 2015年 mac. All rights reserved.
//

import UIKit

class EmotionAttachment: NSTextAttachment {
    
    //--------------step<31>---实现附件对象记录表情文字----------------------------------------------------------
    var chs: String?
    
    // 将图片附件转换为 NSAttributedString 并且返回
    class func NSAttributedStringWithImagePath(emosion: Emotions, height: CGFloat) -> NSAttributedString
    {
        

        ///Step: <23> 创建图片属性文本
        //        let attachment = NSTextAttachment()
        let attachment = EmotionAttachment() ///Step: <31>
        attachment.chs = emosion.chs
        attachment.image = UIImage(contentsOfFile: emosion.imagePath!)
        ///Step: <28> 修改图片大小
        attachment.bounds = CGRectMake(0, 0, height, height) ///Step: <28>
        return  NSAttributedString(attachment: attachment)

        
    }
    
    
   
}
